<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var obj = {
            a:1,
            b:{
                bson:2
            },
            c:['mother','father']
        }
        var copyobj = obj
        let copyNewobj = deepClone(obj)
        obj.a = 2
        obj.b.bson = 9
        console.log(Object.values(obj))
        function deepClone(obj){
            //如果obj下边是否还有值
            //如果有就往下一层继续找，如果没有的话就copy一份给新值
            //let result = {} //创建一个新的对象
            let result = Array.isArray(obj) ? [] : {}
            if (obj && typeof obj == 'object') {
                for(item in obj){
                    if(typeof obj[item] === 'object'){
                        result[item] = deepClone(obj[item])
                    }else{
                        result[item] = obj[item]
                    }
                }
                return result
            }else{
                //如果obj不是对象，那么直接返回值就可以了
                return obj
            }
           
        }
        console.log(obj)
        console.log(copyobj)
        console.log(copyNewobj)
    </script>
</body>
</html>